package onki.tests;

import onki.tests.pageObjects.OnkiConceptPageObject;
import java.util.ArrayList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.PageFactory;

@Test(groups = {"finnish"})
public class CatCompletenessFI extends OnkiTestBase {

  private WebDriver driver;
  private OnkiConceptPageObject catConceptPage;

  public CatCompletenessFI() {
    conceptUri = "http://www.yso.fi/onto/yso/p19378";
  }

  @BeforeClass
  public void setUp() {
    driver = new FirefoxDriver();
    this.catConceptPage = loadConcept(conceptUri, "fi");
  }
  
  public void hasProperTitle() {
    assertTrue(this.driver.getTitle().contains("YSO: kissa"));
  }
  
  public void hasProperPrefLabel() {
    assertTrue(this.catConceptPage.getPrefLabel().contentEquals("kissa"));
  }
  
  public void hasProperBreadCrumbs() {
    ArrayList<String> labels = this.catConceptPage.getBreadCrumbLabels();
    boolean allCrumbsFound = true;
    String[] correctLabels = {"oliot", "fyysinen objekti", "orgaaninen rakenne", "eliöt", "aitotumaiset", "eläimet", "selkäjänteiset", "selkärankaiset", "nisäkkäät", "petoeläimet", "kissaeläimet"};
    for (String label : correctLabels)
      if (!labels.contains(label))
        allCrumbsFound = false;

    assertTrue(allCrumbsFound);
  }

  @AfterClass
  public void tearDown() {
    driver.quit();
  }

  public OnkiConceptPageObject loadConcept(String uri, String lang) {
    this.driver.get(lightenUrl(uri, lang));
    OnkiConceptPageObject cat = PageFactory.initElements(this.driver, OnkiConceptPageObject.class);
    return cat;
  }
}
